package com.example.sls.mapper.teacher.pro;

import com.example.sls.pojo.teacher.pro.Pro;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository

public interface ProMapper {
    @Select("select * from pro")
    List<Pro> getProsInfo();  //查询所有题目

    @Select("select * from pro where setId = #{setId}")
    List<Pro> getProsBySetId(@Param("setId") Integer setId);   //通过题集号获取指定题集所有题目


    @Select("select id from pro where setId = #{setId}")
    List<Integer> getProIdBySetId(@Param("setId") Integer setId);   //通过题集号获取指定题集所有题号(分页)


    //通过id获取题目所有信息
    @Select("select id, setId, content from pro where id = #{id}")
    @Results(id="proInfoMap", value = {
            @Result(column = "id", property = "id"),
            @Result(column = "setId", property = "setId"),
            @Result(column = "content", property = "content")
            })
    Pro getProInfoById(@Param("id") Integer id);


    @Select("select * from pro where id = #{id}")
    Pro getProById(@Param("id") Integer id);


    @Insert("insert into pro values(#{id}, #{setId}, #{proType},#{content},#{correctSQL},#{result});")
    Integer addPro(Pro pro);  //(教师)添加题目

    @Select("select max(id) from pro;")
    Integer getMaxId();  //获取题目最大id

    @Select("select count(*) from pro;")
    Integer getCount();  //获取题目数量
}
